package com.lizhi.yun.core.parameters.handler;/**
 * @program: sfrobot-html
 * @name UppParametersHandler
 * @description:
 * @author: lizhi
 * @create: 2020-04-23 14:19
 */

import com.lizhi.common.yun.entity.ListResponseResult;
import com.lizhi.yun.db.dao.UppParametersDao;
import com.lizhi.yun.db.pojo.UppParametersPOJO;
import com.lizhi.mybatis.interceptor.PageBounds;
import com.lizhi.utils.DateUtils;
import com.lizhi.yun.base.BaseHandler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 *@program: sfrobot-html
 *@name UppParametersHandler
 *@description:
 *@author: lizhi
 *@create: 2020-04-23 14:19
 */
@Slf4j
@Service
public class UppParametersHandler extends BaseHandler {

    @Resource
    private UppParametersDao uppParametersDao;

    /**
     *功能描述 分页查询
     * @author lizhi
     * @date 2020/4/23
     * @param map:
     * @return com.lizhi.common.base.PagerView<com.lizhi.db.upp.pojo.UppParametersPOJO>
     */
    public ListResponseResult Main(Map<String,Object> map) {
        PageBounds pageBounds = getPageBounds(map);
        List<UppParametersPOJO> doList = uppParametersDao.selectByMap(map, pageBounds);
        return getListResult(pageBounds.getCountRows(), doList, map);
    }

    /**
     *功能描述 浏览
     * @author lizhi
     * @date 2020/4/23
     * @param code:
     * @return com.lizhi.db.upp.pojo.UppParametersPOJO
     */
    public ListResponseResult selectById(String code) {
        UppParametersPOJO entity = uppParametersDao.selectById(code);
        return getListResult(entity);
    }


    /**
     *功能描述  新增
     * @author lizhi
     * @date 2020/4/23
     * @param bgbcParametersDO:
     * @return int
     */
    public ListResponseResult Add(UppParametersPOJO bgbcParametersDO) {
        bgbcParametersDO.setInsertTime(DateUtils.getNowDate());
        log.info("系统参数管理得到的新增信息是bgbcParametersDO:{}",bgbcParametersDO);
        int i = uppParametersDao.insertRecord(bgbcParametersDO);
        return getListResult(i);
    }

    /**
     *功能描述 更新
     * @author lizhi
     * @date 2020/4/23
     * @param bgbcParametersDO:
     * @return int
     */
    public ListResponseResult Update(UppParametersPOJO bgbcParametersDO) {
        bgbcParametersDO.setUpdateTime(DateUtils.getNowDate());
        log.info("系统参数管理得到修改信息是bgbcParametersDO:{}",bgbcParametersDO);
        int i = uppParametersDao.updateByIdSelective(bgbcParametersDO);
        return getListResult(i);
    }

    /**
     *功能描述 删除信息
     * @author lizhi
     * @date 2020/11/14
     * @param code:
     * @return com.lizhi.common.yun.entity.ListResponseResult
     */
    public ListResponseResult doDelete(String code){
        int i = uppParametersDao.deleteById(code);
        return getListResult(i);
    }
}
